home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / misc / mirrorman_1_10b1.lha / MirrorManager-1.10b1 / rexx / CleanupIncoming.mm next >
Text File  |  1994-06-24  |  21KB  |  644 lines

  1. /*rx
  2.     $VER: $Id: CleanupIncoming.mm,v 1.9 1994/06/20 01:08:16 tf Exp $
  3.  
  4.     This script examines (non-recursively) the files in your INCOMING
  5.     directory and looks them up in an Aminet mirror INDEX file.
  6.     For each file in your INCOMING directory which is listed exactly
  7.     *once* in the aminet index file the following actions can be
  8.     performed:
  9.  
  10.     o  A filenote (comment) can be added according to the one listed
  11.        in your Aminet index file and
  12.  
  13.     o  The file can be copied (or moved) to the location listed
  14.        in the aminet index.
  15.  
  16.     (The Aminet directory hierarchy can be created using 'MakeTree.rexx')
  17.  
  18.     This ARexx script needs the AmigaDOS commands "List", "Sort",
  19.     "Search", "Filenote", "Copy" and "Delete" available in your path.
  20.  
  21.     Initial revision by Tobias Ferber, 22-Feb-94
  22. */
  23.  
  24. options results
  25. options failat 10
  26.  
  27. call pragma('S',102400)
  28.  
  29. /* initialize globals */
  30.  
  31. frompath   = ""  /* incoming directory */
  32. topath     = ""  /* path to the Aminet mirror */
  33. indexpath  = ""  /* Aminet index file or FAST index path */
  34. mapfile    = ""  /* remap tree file */
  35.  
  36. fastprefix = "FAST."
  37. tempfile   = "T:CleanupIncomingTemp." || pragma('Id')
  38. tempinfo   = "T:CleanupIncomingTempInfo." || pragma('Id')
  39. template   = "FROM/K/A,TO/K,WITH=INDEX/K/A,MOVE/S,COPY/S,NOCOMMENT/S,MAKEPATH/S,REPLACE/S,FAST/S,REMAP/K,LONG/S,AUTO/S"
  40. args       = ""
  41. cliopts    = ""
  42.  
  43. dg       = 0  /* gauge increment */
  44. gstepN   = 0
  45.  
  46. ESC      = '1b'x
  47.  
  48. signal on HALT
  49. signal on BREAK_C
  50. signal on BREAK_D
  51.  
  52.  
  53. /* parse args */
  54.  
  55. do ac=1 while ac <= arg()
  56.   av= arg(ac)
  57.   select
  58.     when upper(av) = "FROM" then do
  59.       if ac < arg() then do
  60.         ac= ac+1
  61.         frompath= arg(ac)
  62.         if words(frompath) < 1 then frompath= pragma('D')
  63.         end
  64.       else exit bad_args('Missing pathname after' ESC'bFROM'ESC'n keyword.')
  65.       end /* FROM */
  66.  
  67.     when upper(av) = "TO" then do
  68.       if ac < arg() then do
  69.         ac= ac+1
  70.         topath= arg(ac)
  71.         if words(topath) < 1 then topath= pragma('D')
  72.         end
  73.       else exit bad_args('Missing pathname after' ESC'bTO'ESC'n keyword.')
  74.       end /* TO */
  75.  
  76.     when (upper(av) = "INDEX") | (upper(av) = "WITH") then do
  77.       if ac < arg() then do
  78.         ac= ac+1
  79.         indexpath= arg(ac)
  80.         end
  81.       else exit bad_args('Missing index pathname after' ESC'b'upper(av)ESC'n keyword.')
  82.       end /* INDEX,WITH */
  83.  
  84.     when upper(av) = "REMAP" then do
  85.       if ac < arg() then do
  86.         ac= ac+1
  87.         mapfile= arg(ac)
  88.         end
  89.       else exit bad_args('Missing remap filename after' ESC'bREMAP'ESC'n keyword.')
  90.       end /* INDEX,WITH */
  91.  
  92.     when upper(av) = "COPY" then do
  93.       if (lastpos('d',cliopts) < 1) then cliopts = cliopts || 'c'
  94.       else exit bad_args('Only one of' ESC'bCOPY'ESC'n or' ESC'bMOVE'ESC'n is allowed.')
  95.       end /* COPY */
  96.  
  97.     when upper(av) = "MOVE" then do
  98.       if (lastpos('c',cliopts) < 1) then cliopts = cliopts || 'cd'
  99.       else exit bad_args('Only one of' ESC'bCOPY'ESC'n or' ESC'bMOVE'ESC'n is allowed.')
  100.       end /* MOVE */
  101.  
  102.     when upper(av) = "NOCOMMENT" then cliopts = cliopts || 'n'
  103.     when upper(av) = "MAKEPATH"  then cliopts = cliopts || 'm'
  104.     when upper(av) = "REPLACE"   then cliopts = cliopts || 'r'
  105.     when upper(av) = "FAST"      then cliopts = cliopts || 'f'
  106.     when upper(av) = "LONG"      then cliopts = cliopts || 'l'
  107.     when upper(av) = "AUTO"      then cliopts = cliopts || 'a'
  108.  
  109.     otherwise exit bad_args('Unknown keyword:' ESC'b' || av || ESC'n')
  110.  
  111.   end /* select */
  112.  
  113. end /* do */
  114.  
  115. call pragma('W','N')
  116.  
  117.  
  118. if (words(mapfile) > 0) & ~exists(mapfile) then do
  119.   REQUESTCHOICE TITLE   '"CleanupIncoming Request"',
  120.                 BODY    '"CleanupIncoming failed to locate your remap file*n*n' ||,
  121.                         ESC'c'ESC'b' || mapfile || ESC'n'ESC'l'                 || '"',
  122.                 GADGETS '"Exit"'
  123.   exit 10
  124.   end
  125.  
  126.  
  127. /* try to get missing index path or file */
  128.  
  129. if words(indexpath) < 1 then do
  130.   cwd= strip(pragma('D'),'B','"')
  131.   if pos('f',cliopts) > 0 then REQUESTFILE DRAWER '"'cwd'"' TITLE '"Select fast index path..."' DRAWERSONLY NOICONS
  132.                           else REQUESTFILE DRAWER '"'cwd'"' TITLE '"Select an index file..."' NOICONS
  133.   if (rc=0) & (words(result) > 0) & (result ~= 'RESULT') then indexpath= result
  134.   end
  135.  
  136. if words(indexpath) < 1 then
  137.   exit bad_args("Not enough arguments for CleanupIncoming...  Exiting...")
  138.  
  139. if ~exists(indexpath) then do
  140.   REQUESTCHOICE TITLE   '"CleanupIncoming Request"',
  141.                 BODY    '"CleanupIncoming failed to locate your index path*n*n' ||,
  142.                         ESC'c'ESC'b' || indexpath || ESC'n'ESC'l'               || '"',
  143.                 GADGETS '"Exit"'
  144.   exit 10
  145.   end
  146.  
  147.  
  148. /* try to get missing from path */
  149.  
  150. if words(frompath) < 1 then do
  151.   cwd= strip(pragma('D'),'B','"')
  152.   REQUESTFILE DRAWER '"'cwd'"' TITLE '"Select the source directory..."' DRAWERSONLY NOICONS
  153.   if (rc=0) & (words(result) > 0) & (result ~= 'RESULT') then frompath= result
  154.   end
  155.  
  156. if words(frompath) < 1 then
  157.   exit bad_args("Not enough arguments for CleanupIncoming...  Exiting...")
  158.  
  159. if ~exists(frompath) then do
  160.   REQUESTCHOICE TITLE   '"CleanupIncoming Request"',
  161.                 BODY    '"CleanupIncoming failed to locate your source directory*n*n' ||,
  162.                         ESC'c'ESC'b' || frompath || ESC'n'ESC'l'                      || '"',
  163.                 GADGETS '"Exit"'
  164.   exit 10
  165.   end
  166.  
  167.  
  168. /* eventually try to get missing destination path */
  169.  
  170. if (pos('c',cliopts) > 0) then do
  171.   if words(topath) < 1 then do
  172.     cwd= strip(pragma('D'),'B','"')
  173.     REQUESTFILE DRAWER '"'cwd'"' TITLE '"Select the destination direcory..."' DRAWERSONLY NOICONS SAVEMODE
  174.     if (rc=0) & (words(result) > 0) & (result ~= 'RESULT') then topath= result
  175.     end
  176.  
  177.   if words(topath) < 1 then
  178.     exit bad_args("Not enough arguments for CleanupIncoming...*nExiting...")
  179.  
  180.   if ~exists(topath) & canexist(topath) then do
  181.     if pos('m',cliopts) > 0 then call makepath(topath)
  182.     else do
  183.       REQUESTCHOICE TITLE   '"CleanupIncoming Request"',
  184.                     BODY    '"Destination path*n*n'                      ||,
  185.                             ESC'c'ESC'b' || topath || ESC'n'ESC'l*n*n'   ||,
  186.                             'does not exist.  Shall I create it?'        || '"',
  187.                     GADGETS '"_Yes|_All|_No"'
  188.       if result > 0 then do
  189.         if result > 1 then cliopts = cliopts || 'm'
  190.         call makepath(topath)
  191.         end
  192.       else do
  193.         REQUESTCHOICE TITLE   '"CleanupIncoming Request"',
  194.                       BODY    '"Operation canceled."',
  195.                       GADGETS '"Exit"'
  196.         exit
  197.         end
  198.       end
  199.     if exists(topath) then MESSAGE '"'topath'   [created]"'
  200.     end
  201.  
  202.   if ~exists(topath) then do
  203.     REQUESTCHOICE TITLE   '"CleanupIncoming Request"',
  204.                   BODY    '"CleanupIncoming failed to create your destination path*n*n' ||,
  205.                           ESC'c'ESC'b' || topath || ESC'n'ESC'l'                        || '"',
  206.                   GADGETS '"Exit"'
  207.     exit 10
  208.     end
  209.   end
  210.  
  211. signal on ERROR
  212. signal on IOERR
  213.  
  214. signal on FAILURE
  215. /*signal on NOVALUE*/
  216. signal on SYNTAX
  217.  
  218.  
  219. /* do the hard part */
  220.  
  221. MESSAGE CLEAR; MESSAGE OPEN; WORKING '"Collecting files... Please wait..."'
  222. address command 'List FILES DIR "' || frompath || '" LFORMAT "%n" TO "' || tempfile || '"'
  223.  
  224. CALL init_gauge(tempfile,2)
  225.  
  226. /* eventually sort the tempfile (speeds up FAST option for disk cache tools) */
  227.  
  228. lib= show('L',"rexxsupport.library")
  229. if ~lib then lib= addlib("rexxsupport.library",0,-30,0)
  230.  
  231. if lib then do
  232.   if value( word(statef(tempfile),2) ) > 0 then 
  233.     address command 'Sort FROM "' || tempfile || '" TO "' || tempfile || '"'
  234.   call remlib("rexxsupport.library")
  235.   end
  236. else say 'Warning: rexxsupport.library not available; processing file list unsorted ...'
  237.  
  238. if ~open('fp',tempfile,'R') then do
  239.   REQUESTCHOICE TITLE   '"CleanupIncoming Request"',
  240.                 BODY    '"Could not open temporary file*n*n'     ||,
  241.                         ESC'c'ESC'b' || tempfile || ESC'n'ESC'l' || '"',
  242.                 GADGETS '"Exit"'
  243.   exit 10
  244.   end
  245.  
  246. do until eof('fp')
  247.  
  248.   fname= strip( readln('fp') )
  249.   if (words(fname) > 0) & (pos('|',fname) < 1) then do
  250.  
  251.     if pos('f',cliopts) > 0 then indexfile = tackon(indexpath,fastprefix) || upper(left(fname,1))
  252.                             else indexfile = indexpath
  253.  
  254.     if exists(indexfile) then do
  255.       MESSAGE transquote('Searching for "'fname'" in' indexfile '...')
  256.  
  257.       signal off ERROR
  258.       address command searchcmd(fname,indexfile)
  259.       signal on ERROR
  260.  
  261.       if ~open('ifp',tempinfo,'R') then do
  262.         REQUESTCHOICE TITLE   '"CleanupIncoming Request"',
  263.                       BODY    '"Search failed.  Could not open*n*n'    ||,
  264.                               ESC'c'ESC'b' || tempinfo || ESC'n'ESC'l' || '"',
  265.                       GADGETS '"Exit"'
  266.         call close('fp')
  267.         exit 10
  268.         end
  269.  
  270.       fnote = ""
  271.       fdir = ""
  272.       matches = 0
  273.  
  274.       CALL step_gauge(1)
  275.  
  276.       do until eof('ifp') | matches > 1
  277.         istr= strip( readln('ifp') )
  278.  
  279.         if words(istr) > 0 then do
  280.           if pos('l',cliopts) > 0 then parse var istr f d . . 42 c  /* LONG index file */
  281.                                   else parse var istr f d .   38 c
  282.  
  283.           if f = fname then do
  284.             if matches = 0 then do
  285.               fnote = c
  286.               fdir  = d
  287.               matches= matches + 1
  288.               end
  289.             else if (fnote ~= c) | (fdir ~= d) then matches= matches + 1
  290.             end
  291.           end
  292.  
  293.           /* else we matched the comment */
  294.  
  295.         end /* scan ifp */
  296.  
  297.       call close('ifp')
  298.  
  299.       fromfile = tackon(frompath,fname)
  300.  
  301.       if exists(fromfile) then do   /* Maybe someone deleted our fromfile meanwhile... */
  302.  
  303.         select /* #of matches */
  304.  
  305.           when matches = 1 then do
  306.  
  307.             if pos('n',cliopts) < 1 then do
  308.               fnote= transquote(fnote)
  309.               MESSAGE transquote('Adding filenote' fnote 'to' '"'fromfile'"')
  310.               address command 'Filenote QUIET FILE' fromfile 'COMMENT' fnote
  311.               end
  312.  
  313.             if pos('c',cliopts) > 0 then do
  314.  
  315.               if words(mapfile) > 0 then do
  316.                 MESSAGE transquote('Searching for' fdir 'in' mapfile '...')
  317.  
  318.                 signal off ERROR
  319.                 address command searchcmd(fdir,mapfile)
  320.                 signal on ERROR
  321.  
  322.                 if ~open('ifp',tempinfo,'R') then do
  323.                   REQUESTCHOICE TITLE   '"CleanupIncoming Request"',
  324.                                 BODY    '"Search failed.  Could not open*n*n'    ||,
  325.                                         ESC'c'ESC'b' || tempinfo || ESC'n'ESC'l' || '"',
  326.                                 GADGETS '"Exit"'
  327.                   call close('fp')
  328.                   exit 10
  329.                   end
  330.  
  331.                 mappings= 0
  332.                 do until eof('ifp') | (mappings > 1)
  333.                   istr= strip( readln('ifp') )
  334.                   if (words(istr) > 0) & (left(istr,1) ~= '#') then do
  335.                     parse var istr src dst
  336.                     dst= strip(dst)
  337.  
  338.                     if (upper(src) = upper(fdir)) then do
  339.                       if words(dst) < 1 then dst= src
  340.                       mappings= mappings + 1
  341.                       end
  342.  
  343.                     end
  344.                   end /* do */
  345.  
  346.                 call close('ifp')
  347.  
  348.                 if mappings = 1 then do
  349.                   if pos(':',dst) > 0 then destpath= dst
  350.                                       else destpath= tackon(topath,dst)
  351.                   end
  352.  
  353.                 end
  354.  
  355.               else do /* no mapfile */
  356.                 if fdir ~= "." then destpath= tackon(topath,fdir)
  357.                                else destpath= topath
  358.                 mappings= 1  /* not remapped */
  359.                 end
  360.  
  361.  
  362.               select /* #of mappings */
  363.  
  364.                 when mappings = 1 then do   /* or if not remapped */
  365.  
  366.                   if ~exists(destpath) & canexist(destpath) then do
  367.                     if pos('m',cliopts) > 0 then call makepath(destpath)
  368.                     else do
  369.                       REQUESTCHOICE TITLE   '"CleanupIncoming Request"',
  370.                                     BODY    '"Destination path*n*n'                      ||,
  371.                                             ESC'c'ESC'b' || destpath || ESC'n'ESC'l*n*n' ||,
  372.                                             'does not exist.  Shall I create it?'        || '"',
  373.                                     GADGETS '"_Yes|_All|_No"'
  374.                       if result > 0 then do
  375.                         if result > 1 then cliopts = cliopts || 'm'
  376.                         call makepath(destpath)
  377.                         end
  378.                       end
  379.                     if exists(destpath) then MESSAGE '"'destpath'   [created]"'
  380.                     end
  381.  
  382.                   if exists(destpath) then do
  383.                     tofile= tackon(destpath,fname)
  384.                     MESSAGE transquote('Copying "'fromfile'" to "'tofile'" ...')
  385.                     if exists(tofile) then do
  386.                       if pos('r',cliopts) > 0 then address command 'Copy QUIET CLONE FROM "'fromfile'" TO "'tofile'"'
  387.                       else do
  388.                         REQUESTCHOICE TITLE   '"CleanupIncoming Request"',
  389.                                       BODY    '"'ESC'c'ESC'b' || tofile || ESC'n'ESC'l*n*n' ||,
  390.                                               'already exists.  Shall I replace it?'        || '"',
  391.                                       GADGETS '"_Yes|_All|_No"'
  392.                         if result > 0 then do
  393.                           if result > 1 then cliopts = cliopts || 'r'
  394.                           address command 'Copy QUIET CLONE FROM "'fromfile'" TO "'tofile'"'
  395.                           end
  396.                         else MESSAGE transquote(tofile 'not replaced')
  397.                         end
  398.                       end
  399.                     else address command 'Copy QUIET CLONE FROM "'fromfile'" TO "'tofile'"'
  400.  
  401.                     if (pos('d',cliopts) > 0) & exists(tofile) then do
  402.                       MESSAGE transquote('Removing "'fname'" from' frompath)
  403.                       address command 'Delete QUIET FILE "'fromfile'"'
  404.                       end
  405.                     end
  406.                   else MESSAGE transquote('Warning: "'fname'" ignored.  (Destination path "'destpath'" not created)')
  407.                   end
  408.  
  409.                 when mappings < 1 then do
  410.                   MESSAGE transquote('Warning: path' fdir 'has not been remapped in' mapfile '...' fname 'skipped')
  411.                   end
  412.  
  413.                 otherwise do /* mappings > 1 */
  414.                   MESSAGE transquote('Warning: path' fdir 'has been remapped more than once in' mapfile '...' fname 'skipped')
  415.                   end
  416.  
  417.                 end /* select #of mappings */
  418.  
  419.               end /* pos('c',cliopts) > 0 */
  420.  
  421.             end /* matches = 1 */
  422.  
  423.           when matches = 0 then do
  424.             MESSAGE transquote('Warning: file "'fname'" not found in index file "'indexfile'"')
  425.             end
  426.  
  427.           otherwise do
  428.             MESSAGE transquote('Warning: filename "'fname'" is ambiguous ... skipped')
  429.             end
  430.  
  431.           end /* select */
  432.  
  433.         end /* exists(fromfile) */
  434.  
  435.       else MESSAGE transquote('Warning: "'fromfile'" does not exist anymore ... ignored')
  436.       address command 'Delete QUIET FILE "' || tempinfo || '"'
  437.  
  438.       end /* exists(indexfile) */
  439.  
  440.     else MESSAGE transquote('Index file "'indexfile'" does not exist ...  "'fname'" skipped')
  441.  
  442.     end /* have fname */
  443.  
  444.   CALL step_gauge(1)
  445.  
  446.   end /* do scan fp */
  447.  
  448. call close('fp')
  449. MESSAGE '"Deleting temporary file list' tempfile '..."'
  450. address command 'Delete QUIET FILE "' || tempfile || '"'
  451. COMPLETE 100
  452. MESSAGE '"done."'
  453. IF POS('a',cliopts) > 0 THEN MESSAGE CLOSE;
  454. exit 0
  455.  
  456. /**/
  457.  
  458. bad_args: PROCEDURE EXPOSE template ESC
  459.   PARSE ARG msg
  460.  
  461.   REQUESTCHOICE TITLE   '"CleanupIncoming Request"',
  462.                 BODY    '"' || msg || '*n*n'                     ||,
  463.                         'CleanupIncoming args template:*n*n'     ||,
  464.                         ESC'c'ESC'b' || template || ESC'n'ESC'l' || '"',
  465.                 GADGETS '"Okay"'
  466.   RETURN 0
  467.  
  468.  
  469. /* generate the search command string */
  470.  
  471. searchcmd: PROCEDURE EXPOSE tempinfo
  472.   PARSE ARG pattern,file
  473.   return 'Search NONUM > "'tempinfo'" FROM "'file'" SEARCH "'pattern'"'
  474.   /*return 'AGrep > "'tempinfo'"' '"'pattern'"' '"'file'"'*/
  475.  
  476. /*@*/
  477.  
  478.  
  479. /* translate '"' into '*"' and '*' into '**' */
  480.  
  481. transquote: procedure
  482.   parse arg s
  483.   t= s
  484.   q= max( lastpos('*',s), lastpos('"',s) )
  485.   do while q > 0
  486.     t= insert('*',t,q-1,1)
  487.     s= left(s,q-1)
  488.     q= max( lastpos('*',s), lastpos('"',s) )
  489.     end
  490.   return '"' || t || '"'
  491.  
  492.  
  493. /* return the non-file part of a pathname */
  494.  
  495. pathonly: procedure
  496.   parse arg path
  497.   if (words(path) > 0) & (right(path,1) ~= ':') then do
  498.     if right(path,1) = '/' then path= left(path,length(path)-1)
  499.     if lastpos('/',path) > lastpos(':',path) then path= left(path,lastpos('/',path)-1)
  500.                                              else path= left(path,lastpos(':',path))
  501.     end
  502.   return path
  503.  
  504.  
  505. /* return the file part of a pathname */
  506.  
  507. fileonly: procedure
  508.   parse arg path
  509.   if right(path,1) = '/' then path= left(path,length(path)-1)
  510.   p= max( lastpos(':',path), lastpos('/',path) )
  511.   if(p>0) then return substr(path,p+1)
  512.           else return path
  513.  
  514.  
  515. /* concatenate the filename to the pathname and return the resulting string */
  516.  
  517. tackon: procedure
  518.   parse arg path,file
  519.   do while left(file,1) = '/'
  520.     file= substr(file,2)
  521.     path= pathonly(path)
  522.     end
  523.   if (words(path) > 0) & (right(path,1) ~= '/') & (right(path,1) ~= ':') then path= path || '/'
  524.   if (right(file,1) = '/') then file= left(file,length(file)-1)
  525.   return path || file
  526.  
  527.  
  528. /* create all non-existant directories in a path */
  529.  
  530. makepath: procedure
  531.   parse arg path
  532.   if right(path,1) = '/' then path= left(path,length(path)-1)
  533.   if ~exists(path) then do
  534.     call makepath( pathonly(path) )
  535.     address command 'MakeDir NAME "'path'"'
  536.     end
  537.   return 0
  538.  
  539.  
  540. /*
  541.  * return   1  if the device or volume name in given pathname exists
  542.  *             or if no device or volume was present (current device)
  543.  *          0  if the device or volume name does not exist
  544.  */
  545.  
  546. canexist: procedure
  547.   parse upper arg path
  548.   if pos(':',path) < 1 then return 1 /* current device */
  549.   call pragma('W','N')
  550.   return exists( left(path,lastpos(':',path)) )
  551.  
  552.  
  553. /* stretch the blue completion bar */
  554.  
  555. step_gauge: PROCEDURE EXPOSE dg gstepN
  556.   ARG increment
  557.   gstepN= gstepN + 1
  558.   c= MIN(TRUNC(gstepN * increment * dg),100)
  559.   COMPLETE c
  560.   IF c >= 100 THEN WORKING '"done."'
  561.   RETURN 0
  562.  
  563.  
  564. /* initialize the gauge increment by counting the #of steps to be performed */
  565.  
  566. init_gauge: PROCEDURE EXPOSE dg gstepN
  567.   PARSE ARG fname,steps_per_entry
  568.  
  569.   dg = 0         /* gauge increment */
  570.   gstepN = 0     /* #of performed steps */
  571.  
  572.   IF OPEN('fp',fname,'R') THEN DO
  573.     numentries= 0
  574.     DO UNTIL EOF('fp')
  575.       IF WORDS(READLN('fp')) > 0 THEN
  576.         numentries= numentries+1
  577.       END
  578.     WORKING '"Processing' numentries 'entries..."'
  579.     IF (numentries * steps_per_entry) ~= 0 then dg= 100 / (numentries * steps_per_entry)
  580.                                            else dg= 100
  581.     CALL SEEK('fp',0,'B')
  582.     CALL CLOSE('fp')
  583.     END
  584.  
  585.   MESSAGE CLEAR; MESSAGE OPEN;
  586.   COMPLETE 0
  587.   RETURN 0
  588.  
  589.  
  590. /* error/break handling */
  591.  
  592. IOERR:
  593. ERROR:
  594.   err= rc
  595.   ESC = '1b'x
  596.  
  597.   signal off ERROR
  598.   signal off IOERR
  599.  
  600.   WORKING '"I/O problem trapped... Execution halted."'
  601.   MESSAGE '"I/O problem trapped... Execution halted."'
  602.  
  603.   REQUESTCHOICE TITLE   '"CleanupIncoming Error Trap' err'"',
  604.                 BODY    '"There was a problem with external I/O in line' sigl '...*n' ||,
  605.                         ESC'c'ESC'b' || ERRORTEXT(err) || ESC'n'ESC'l'                || '"',
  606.                 GADGETS '"I''ll better exit"'
  607.   exit
  608.  
  609.  
  610. FAILURE:
  611. NOVALUE:
  612. SYNTAX:
  613.   err= rc
  614.   ESC = '1b'x
  615.  
  616.   signal off FAILURE
  617.   signal off NOVALUE
  618.   signal off SYNTAX
  619.  
  620.   WORKING '"Internal problem trapped... Execution halted."'
  621.   MESSAGE '"Internal problem trapped... Execution halted."'
  622.  
  623.   REQUESTCHOICE TITLE   '"CleanupIncoming Internal Error' err'"',
  624.                 BODY    '"CleanupIncoming seems to have an internal problem in line' sigl '...*n' ||,
  625.                         ESC'c'ESC'b' || ERRORTEXT(err) || ESC'n'ESC'l'                            || '"',
  626.                 GADGETS '"I''ll better exit"'
  627.   exit
  628.  
  629.  
  630. HALT:
  631. BREAK_C:
  632. BREAK_D:
  633.   signal off HALT
  634.   signal off BREAK_C
  635.   signal off BREAK_D
  636.  
  637.   WORKING '"Break signal trapped... Execution halted."'
  638.   MESSAGE '"Break signal trapped... Execution halted."'
  639.  
  640.   REQUESTCHOICE TITLE   '"CleanupIncoming Break Trap"',
  641.                 BODY    '"Script execution halted."',
  642.                 GADGETS '"Stop"'
  643.   exit
  644.